using HOS.Application.Support.Framework.DataAccess;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Text;

namespace K9MPro.Business
{
    /// <summary>
    /// Provide a common interface to the data from the UI that
    /// is loosely coupled so that these methods could be called
    /// from anywhere in the application without dependencies.
    /// </summary>
    public class DataServices
    {

        #region Deprecated Code
        //#region Class Variables

        //// Get References To The Data
        //string K9_DataCnn = ConfigurationManager.ConnectionStrings["HT_DataCnn"].ConnectionString;

        //#endregion

        //#region User Account Data Services

        ///// <summary>
        ///// Validates a users login as well as gets the account information for a user
        ///// </summary>
        ///// <param name="userName"></param>
        ///// <param name="password"></param>
        ///// <returns>DataTable</returns>
        //public User GetUserAccountInformationByLoginCredentialsOrId(string loginName, string password, int userId)
        //{
        //    Database myDB = new Database(Database.DB_Type.dbMSSQL, K9_DataCnn);
        //    DataAccess myDA = new DataAccess(myDB);
        //    DataTable myDT = new DataTable("UserAccountInfo");
        //    DataRow myDR;

        //    if (userId > 0)
        //    {
        //        SqlParameter[] myParams = new SqlParameter[1];
        //        SqlParameter param_UserId = new SqlParameter();
        //        param_UserId.SqlDbType = SqlDbType.Int;
        //        param_UserId.ParameterName = "@userId";
        //        param_UserId.Value = userId;
        //        myParams[0] = param_UserId;

        //        myDT = myDA.Exec_MSSQL_StoredProc_DT("dbo.GetUserAccountInformationByUserId", myParams, "UserAccountInfo");
        //    }
        //    else
        //    {
        //        SqlParameter[] myParams = new SqlParameter[2];
        //        SqlParameter param_LoginName = new SqlParameter();
        //        param_LoginName.SqlDbType = SqlDbType.VarChar;
        //        param_LoginName.ParameterName = "@loginName";
        //        param_LoginName.Value = loginName;
        //        myParams[0] = param_LoginName;

        //        SqlParameter param_Password = new SqlParameter();
        //        param_Password.SqlDbType = SqlDbType.VarChar;
        //        param_Password.ParameterName = "@password";
        //        param_Password.Value = password;
        //        myParams[1] = param_Password;

        //        myDT = myDA.Exec_MSSQL_StoredProc_DT("dbo.GetUserAccountInformationByLoginCredentials", myParams, "UserAccountInfo");
        //    }


        //    if (myDT.Rows.Count == 1)
        //    {
        //        User vu = new User();
        //        myDR = myDT.Rows[0];

        //        vu.ID = Convert.ToInt32(myDR.ItemArray[myDR.Table.Columns["ID"].Ordinal]);
        //        vu.AccountPassword = myDR.ItemArray[myDR.Table.Columns["AccountPassword"].Ordinal].ToString();
        //        vu.Created = (DateTime)myDR.ItemArray[myDR.Table.Columns["Created"].Ordinal];
        //        vu.FirstName = myDR.ItemArray[myDR.Table.Columns["FirstName"].Ordinal].ToString();
        //        vu.LastName = myDR.ItemArray[myDR.Table.Columns["LastName"].Ordinal].ToString();
        //        vu.LastUpdated = (DateTime)myDR.ItemArray[myDR.Table.Columns["LastUpdated"].Ordinal];
        //        vu.LoginName = myDR.ItemArray[myDR.Table.Columns["LoginName"].Ordinal].ToString();
        //        vu.Region = myDR.ItemArray[myDR.Table.Columns["Region"].Ordinal].ToString();
        //        vu.SecurityLevel = Convert.ToInt32(myDR.ItemArray[myDR.Table.Columns["AccountPassword"].Ordinal]);
        //        vu.UserStatus = (userStatus)myDR.ItemArray[myDR.Table.Columns["UserStatus"].Ordinal];
        //        vu.UserType = (userType)myDR.ItemArray[myDR.Table.Columns["UserType"].Ordinal];
                
        //        return vu;
        //    }
        //    else
        //    {
        //        return null;
        //    }
        //}

        ///// <summary>
        ///// Get a users account information by User ID
        ///// </summary>
        ///// <param name="userID"></param>
        ///// <returns>DataTable</returns>
        //public User GetUserAccountInformation(int userID)
        //{
        //    Database myDB = new Database(Database.DB_Type.dbMSSQL, K9_DataCnn);
        //    DataAccess myDA = new DataAccess(myDB);
        //    DataTable myDT = new DataTable("UserAccountInfo");
        //    DataRow myDR;
        //    SqlParameter[] myParams = new SqlParameter[1];
        //    SqlParameter param_UserID = new SqlParameter();

        //    // Setup the sql parameter(s)
        //    param_UserID.SqlDbType = SqlDbType.Int;
        //    param_UserID.ParameterName = "@user_id";
        //    param_UserID.Value = userID;
        //    myParams[0] = param_UserID;
        //    // Get the data from a DAL
        //    myDT = myDA.Exec_MSSQL_StoredProc_DT("dbo.Get_User_Account_Information_By_UserID", myParams, "UserAccountInfo");

        //    if (myDT.Rows.Count == 1)
        //    {
        //        User vu = new User();
        //        myDR = myDT.Rows[0];

        //        vu.ID = Convert.ToInt32(myDR.ItemArray[myDR.Table.Columns["ID"].Ordinal]);
        //        vu.AccountPassword = myDR.ItemArray[myDR.Table.Columns["AccountPassword"].Ordinal].ToString();
        //        vu.Created = (DateTime)myDR.ItemArray[myDR.Table.Columns["Created"].Ordinal];
        //        vu.FirstName = myDR.ItemArray[myDR.Table.Columns["FirstName"].Ordinal].ToString();
        //        vu.LastName = myDR.ItemArray[myDR.Table.Columns["LastName"].Ordinal].ToString();
        //        vu.LastUpdated = (DateTime)myDR.ItemArray[myDR.Table.Columns["LastUpdated"].Ordinal];
        //        vu.LoginName = myDR.ItemArray[myDR.Table.Columns["LoginName"].Ordinal].ToString();
        //        vu.Region = myDR.ItemArray[myDR.Table.Columns["Region"].Ordinal].ToString();
        //        vu.SecurityLevel = Convert.ToInt32(myDR.ItemArray[myDR.Table.Columns["AccountPassword"].Ordinal]);
        //        vu.UserStatus = (userStatus)myDR.ItemArray[myDR.Table.Columns["UserStatus"].Ordinal];
        //        vu.UserType = (userType)myDR.ItemArray[myDR.Table.Columns["UserType"].Ordinal];

        //        return vu;
        //    }
        //    else
        //    {
        //        return null;
        //    }
        //}

        ///// <summary>
        ///// Update a users account information
        ///// </summary>
        ///// <param name="useraccount"></param>
        ///// <returns>Returns an integer specifying rows affected</returns>
        //public int UpdateUserAccountInfo(User useraccount)
        //{
        //    Database myDB = new Database(Database.DB_Type.dbMSSQL, K9_DataCnn);
        //    DataAccess myDA = new DataAccess(myDB);
        //    SqlParameter[] myParams = new SqlParameter[8];

        //    // Setup the sql parameter(s)
        //    SqlParameter param_UserID = new SqlParameter();
        //    param_UserID.SqlDbType = SqlDbType.Int;
        //    param_UserID.ParameterName = "@userId";
        //    param_UserID.Value = useraccount.ID ;
        //    myParams[0] = param_UserID;

        //    SqlParameter param_LastName = new SqlParameter();
        //    param_LastName.SqlDbType = SqlDbType.VarChar;
        //    param_LastName.ParameterName = "@lastName";
        //    param_LastName.Value = useraccount.LastName;
        //    myParams[1] = param_LastName;

        //    SqlParameter param_FirstName = new SqlParameter();
        //    param_FirstName.SqlDbType = SqlDbType.VarChar;
        //    param_FirstName.ParameterName = "@firstName";
        //    param_FirstName.Value = useraccount.FirstName;
        //    myParams[2] = param_FirstName;

        //    SqlParameter param_UserName = new SqlParameter();
        //    param_UserName.SqlDbType = SqlDbType.VarChar;
        //    param_UserName.ParameterName = "@userName";
        //    param_UserName.Value = useraccount.LoginName;
        //    myParams[4] = param_UserName;

        //    SqlParameter param_Password = new SqlParameter();
        //    param_Password.SqlDbType = SqlDbType.VarChar;
        //    param_Password.ParameterName = "@password";
        //    param_Password.Value = useraccount.AccountPassword;
        //    myParams[5] = param_Password;

        //    SqlParameter param_Administrator = new SqlParameter();
        //    param_Administrator.SqlDbType = SqlDbType.Int;
        //    param_Administrator.ParameterName = "@administrator";
        //    param_Administrator.Value = Convert.ToInt32(useraccount.UserType);
        //    myParams[6] = param_Administrator;

        //    SqlParameter param_Lastupdated = new SqlParameter();
        //    param_Lastupdated.SqlDbType = SqlDbType.DateTime;
        //    param_Lastupdated.ParameterName = "@lastupdated";
        //    param_Lastupdated.Value = useraccount.LastUpdated;
        //    myParams[7] = param_Lastupdated;

        //    // Return the number of rows
        //    return myDA.Exec_MSSQL_StoredProc_INT("dbo.Update_UserAccount_Information", myParams);
        //}

        //#endregion

        //#region Utility Data Services

        ///// <summary>
        ///// Get a single log entry based on the logid
        ///// </summary>
        ///// <param name="logID"></param>
        ///// <returns></returns>
        //public DataTable GetDDLData(int ddl_Id, string tableName)
        //{
        //    Database myDB = new Database(Database.DB_Type.dbMSSQL, K9_DataCnn);
        //    DataAccess myDA = new DataAccess(myDB);
        //    DataTable myDT = new DataTable(tableName);
        //    SqlParameter[] myParams = new SqlParameter[1];
        //    SqlParameter param_DDLID = new SqlParameter();

        //    // Setup the sql parameter(s)
        //    param_DDLID.SqlDbType = SqlDbType.Int;
        //    param_DDLID.ParameterName = "@DDL_ID";
        //    param_DDLID.Value = ddl_Id;

        //    // Add the parameter to the params array
        //    myParams[0] = param_DDLID;

        //    // Get the data from the DAL
        //    myDT = myDA.Exec_MSSQL_StoredProc_DT("dbo.Get_DDL_Data_By_DDLID", myParams, tableName);

        //    // Return the dataset to the UI
        //    return myDT;
        //}

        //#endregion
        #endregion
    }
}
 